{include file=header.html}
<style type="text/css">
.search th{border:1px solid #ccc;background:#E6EFF6;font-weight:normal;}
.search td{border:1px solid #ccc;}
</style>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/lan.js}"></script>
<script language="javascript" type="text/javascript">
$(function() {
$('th[type="order"]').click(function() {
var order = $(this).attr('field') + '-' + $(this).attr('order');
$('#order').val(order);
$('input[name="search"]').click();
}).css({'cursor': 'pointer', 'color': '#36c'});
var order = $('#order').val().split('-');
var field = $('th[type="order"][field="' + order[0] + '"]');
if (order[1] == 'ASC') {
field.attr('order', 'DESC').text(field.text() + '↑');
} else {
field.attr('order', 'ASC').text(field.text() + '↓');
}
if (order[0] != 'quote_time') {
$('th[type="order"][field="quote_time"]').attr('order', 'DESC');
}
var isdblclick=0;
$('[type="ajax_edit"]').dblclick(function() {
if(isdblclick==0)
{
var value = $(this).html();
}
else if(isdblclick==1)
{
var value = $(this).text();
}
isdblclick=1;
//$(this).unbind('dblclick');
//var value = $(this).html();
//alert(value);
$(this).html('');
var textarea = $('<textarea style="width:300px; height:80px;" ondblclick="return false;" >' + value + '</textarea>');

//textarea.select();
var id = $(this).attr('id');
var field = $(this).attr('field');
textarea.blur(function() {

var _self = $(this);
$.post('index.php?app=order&act=ajax_edit&id=' + id, {'field' : field, 'value' : $(this).val()}, function(json) {
if (!json.done) {
alert(json.msg);
} else {
isdblclick=0;
_self.parent().html(nl2br(_self.val()));
//_self.parent().bind('dblclick');
}
}, 'json');
});
$(this).append(textarea);
textarea.focus();
});
});
function init_order(order_id) {
$.get('index.php?app=order&act=init_order&id=' + order_id, function(json) {
location.href = location.href;
}, 'json');
}
function nl2br (str) {
var arr = str.split('\n');
var ret = '';
for (var i = 0; i < arr.length; i++) {
ret += arr[i];
if (i != arr.length - 1) {
ret += '<br>\n';
}
}
return ret;
}
</script>
<link href="template/style/css/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="sub-body">
	<div id="head">
		<div  id="search">
			<form action="" method="get">
					<table width="40%" cellspacing="0" cellpadding="0" class="search">
						<tr>
							<th width="100">需求编号：</th>
							<td width="200"><input type="text" id="demand_sn" name="demand_sn" class="input-1" value="{$smarty.get.demand_sn}" /></td>
							<td width="100">
							<input type="hidden" name="app" value="merchant" />
							<input type="hidden" name="act" value="index" />
							<input type="hidden" name="order" id="order" value="{if $smarty.get.order}{$smarty.get.order}{else}demand_time-DESC{/if}" />
							<input type="submit" name="search" value="查询" class="inquiry" /></td>
						</tr>
					</table>
				</form>
		</div>
	</div>
	<div class="tab_info" id="order_list">
		<div class="tab-title-1"><span>需求列表</span></div>
		<table width="100%" cellspacing="0" cellpadding="0" class="tab-display" id="tab-color1">
			<tr>
				<th width="5%">序号</th>
				<th width="10%" type="order" field="demand_time" order="ASC">日期</th>
				<th width="10%" type="order" field="demand_sn" order="ASC">需求编号</th>
				<th width="7%">图片</th>
				<th width="10%">状态</th>
				<!-- {if $user.role neq USER_MERCHANT} -->
				<th width="10%">操作</th>
				<!-- {/if} -->
			</tr>
			<!--{foreach from=$merch_list item=merch key=k name=o}-->
			<tr>
				<td>{$smarty.foreach.o.iteration}</td>
				<td>{$merch.demand_time|date}</td>
				<td><a href="{url app=merchant&act=show&md_id=$merch.md_id}">{$merch.demand_sn|escape}</a></td>
				<td><a href="{$site_url}/{$merch.merch_img}" target="_blank"><img src="{$merch.merch_img}" width="80" style="border:none;" alt="图片"/></a></td>
				<td><!-- {if $merch.demand_status eq 1} -->{$lang.demand_appove}<!-- {elseif $merch.demand_status eq 2} -->{$lang.demand_appoved}<!-- {else} -->{$lang.demand_finish}<!-- {/if} --></td>
				<!-- {if $user.role neq USER_MERCHANT} -->
				<td>
					<!-- {if $smarty.get.act eq 'history_demand'} -->
					<a href="javascript:drop_confirm('您确定要重置该需求吗?','{url app=merchant&act=start_demand&md_id=$merch.md_id}')">重置</a>
					<!-- {else} -->
					<!-- {if $merch.demand_status eq 1} -->
					<a href="javascript:drop_confirm('您确定要删除该需求记录吗?','{url app=merchant&act=drop&md_id=$merch.md_id}')">删除</a>
					<!-- {elseif $merch.demand_status eq 2 && $user.role neq USER_MERCHANT} -->
					<a href="javascript:drop_confirm('您确定要结束该需求吗?','{url app=merchant&act=stop_demand&md_id=$merch.md_id}')">结束</a>
					<!-- {/if} -->
					<!-- {/if} -->
				</td>
				<!-- {/if} -->
			</tr>
			<!--{/foreach}-->
		</table>
		<div class="page"> {include file=page.html}</div>
	</div>
	<div id="order_info"> </div>
</div>
</body>
{$async_sendmail}
</html>
